<template>
  <div class="container"
  :style="{top:wintop,left:winleft}">
    <div class="container_from container--signup"
    >
        <form action="" class="from" id="from1">
            <h2 class="fromtitle">修改密码</h2>
            <input type="text" placeholder="Account" class="input" v-model="account">
            <input type="email" placeholder="Email" class="input" v-model="email">
            <input type="password" placeholder="Password" class="input" v-model="password">
            <button class="btn" @click="updatePwd">确认</button>
            
        </form>
    </div>
    
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            account:'',
            email:'',
            password:'',
            
        }
    },
    methods: {
        GotoLogin(){
            this.$router.push({
                path:'/login'
            })
            alert('Modification succeeded')
        },
        updatePwd(){
            console.log("account",this.account);
            console.log("email",this.email);
            console.log("password",this.password);
            var data = {
                "account":this.account,
                "email":this.email,
                "password":this.password
            }
            axios.post('/updatePwd',data,{
                            headers: {
                                'Content-Type':'application/json; charset=UTF-8;'
                            }
                        }
                ).then(res =>{
                var result = res.data
                alert(result.message)
            }).catch(err=>{
                // this.Pwd_tips=err.response.data.message
                // this.Pwd_tip= true
                // setTimeout(() =>{
                //     this.Pwd_tip= false
                // }, 5000);
                alert(err.response.data.message)
            })
            
        }
    },
    computed:{
        wintop(){
            return (window.innerHeight-50-500)/2+'px'
        },
        winleft(){
            return (window.innerWidth-30-250)/2+'px'
        }
    }
}
</script>

<style scoped>
.container {
    background-color: #e9e9e9;
    border-radius: 0.7rem;
    box-shadow: 0 0.9rem 1.7rem rgba(0, 0, 0, 0.2);
    height: 500px;
    max-width: 300px;
    overflow: hidden;
    position: absolute;
    width: 300px;
}
.from {
    background-color: #e9e9e9;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 0 3rem;
    height: 100%;
    text-align: center;
}
.form>.btn {
    margin-top: 1.5rem;
}
.btn:active {
    transform: scale(0.95);
}
.btn:focus {
    outline: none;
}
.container_from {
    height: 500px;
    position: absolute;
    top: 0;
    transition: all 0.6s ease-in-out;
}
.btn {
    width: 150px;
    height: 50px;
    background-color: skyblue;
    background-image: linear-gradient(90deg, skyblue 0%, #008997 74%);
    border-radius: 20px;
    border: 1px solid skyblue;
    color: #e9e9e9;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 0.1rem;
    text-transform: uppercase;
    transition: transform 80ms ease-in;
    margin-top: 30px;
}
.input {
    background-color: #fff;
    border: none;
    padding: 0.9rem 0.9rem;
    margin: 0.5rem 0;
    width: 100%;
}
.text{
    text-align: center;
}
</style>